﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
namespace Gronia.WPF.Controls
{
    public partial class ConnectContainerResourceDictionary : ResourceDictionary
    {
        void Drag_Started(object sender, DragStartedEventArgs e)
        {
            Thumb t = sender as Thumb;
            DragDrop.DoDragDrop(t, new DataObject(typeof(ConnectPoint), t.Tag), DragDropEffects.Move);
        }

        void Drag_Ended(object sender, DragEventArgs e)
        {
            Thumb t = sender as Thumb;
            ConnectPoint p = t.Tag as ConnectPoint;
            ConnectPoint p2 = e.Data.GetData(typeof(ConnectPoint)) as ConnectPoint;
            if (p != p2)
            {
                p.Parent.Connect(p, p2);
            }
        }

        void OnMouseDown(object sender, MouseEventArgs e)
        {
            Thumb t = sender as Thumb;
            ConnectPoint p = t.Tag as ConnectPoint;
            if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.LeftShift))
            {
                p.Parent.Disconnect(p);
            }
        }
    }
}